package base.thread;

// 实现Runable接口，这里其实是使用了静态代理模式
@SuppressWarnings("all")
public class Thread02 {

    public static void main(String[] args) {
        Dog dog = new Dog();
        Thread thread = new Thread(dog);
        thread.start();
        System.out.println("+++++++++++++++++++++++++++++++++++");
        Tiger tiger = new Tiger();
        Proxy proxy = new Proxy(tiger);
        proxy.start();
    }
}

class Anl{

}
class Tiger extends Anl implements Runnable{

    @Override
    public void run() {
        System.out.println("老虎叫一声.....");
    }
}
class Dog implements Runnable{

    @Override
    public void run() {
        System.out.println("叫一下。。。。");
    }
}

// 静态代理模式的模拟
class Proxy implements Runnable{
    private Runnable target=null;

    @Override
    public void run() {
        if (target!=null){
            target.run();
        }
    }
    Proxy(Runnable target){
        this.target =target;
    }
    public void start(){
        start0();
    }

    private void start0() {
        run();
    }
}